/**
*   类说明
* 
*   @creator         xldc	497937995@qq.com  
*   @create-time     2014年1月20日   下午1:34:32   
*/
package com.huacheng.cms.action.admin;

import javax.servlet.http.HttpServletRequest;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;

import com.huacheng.cms.constant.SystemConstant;
import com.huacheng.cms.exception.BaseException;
import com.huacheng.cms.model.Admin;
import com.huacheng.cms.model.vo.JsonVo;
import com.huacheng.cms.service.AdminService;
import com.huacheng.cms.service.ArticleService;
import com.huacheng.cms.service.CommentService;
import com.huacheng.cms.service.ConfigService;
import com.huacheng.cms.service.FolderService;
import com.huacheng.cms.service.UserService;

public class AdminBaseAction {
	protected final Logger logger = Logger.getLogger(this.getClass());

	@Autowired
	protected ConfigService configSevice;

	@Autowired
	protected FolderService folderService;

	@Autowired
	protected ArticleService articleService;

	@Autowired
	protected UserService userService;
	@Autowired
	protected AdminService adminService;
	@Autowired
	protected CommentService commentService;

	/**
	 * 参数校验
	 * 
	 * @param json
	 *            json数据Bean
	 * @throws ValidateException
	 */
	protected <T> void validate(JsonVo<T> json) throws BaseException {
		if (json.getErrors().size() > 0) {
			json.setResult(false);
			throw new BaseException("有错误发生");
		} else {
			json.setResult(true);
		}
	}

	/**
	 * 从session中获得管理员的信息
	 * 
	 * @param request
	 * @return
	 */
	protected Admin getAdmin(HttpServletRequest request) {
		Admin admin = (Admin) request.getSession().getAttribute(
				SystemConstant.SESSION_ADMIN);
		return admin;
	}
}
